package likong.bibliothek.pages.language;

import java.util.List;

import likong.bibliothek.obj.Autor;
import likong.bibliothek.obj.BuchStatus;
import likong.bibliothek.obj.Language;
import likong.bibliothek.obj.Spender;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.PropertyListView;
import org.hibernate.Session;


import Persondata.Person;
import Persondata.PersonEdit;
import Persondata.PersonLoeschen;
import db.HibernateHelper;

public class LanguageWeb extends LanguageAbstract {

	public LanguageWeb(){
		super(null);
		
		// Alle Sprachen abfragen
		List<Language> languages = HibernateHelper.listAll(Language.class);

		Label noLanguages = new Label("noLanguageInfo");
		PropertyListView<Language> view = new PropertyListView<Language>(
				"languageShow", languages) {
			private static final long serialVersionUID = 1L;

			@Override
			protected void populateItem(ListItem<Language > item) {
				PageParameters params = new PageParameters();
				params.add("languageID", Integer.toString(item.getModel().getObject().getLanguageID()));
				item.add(new BookmarkablePageLink<WebPage>("loeschen", LanguageLoeschen.class, params));
				item.add(new BookmarkablePageLink<WebPage>("bearbeiten", LanguageEdit.class, params));
				item.add(new Label("language"));
			}

		};

		// Blendet das übergeordnete Enclosure (Tabelle, überschrift) aus, wenn
		// Ausgabe leer!
		view.setVisible(languages.size() > 0 ? true : false);
		noLanguages.setVisible(!view.isVisible());
		

		add(view);
		add(noLanguages);
	}
}

	
